<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8" />
        <title>发布投稿-{eyou:global name='web_name' /}</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
        <link href="{eyou:global name='web_cmspath'/}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        {eyou:static file="users/skin/css/eyoucms.css"/}
        {eyou:static file="users/skin/css/element/index.css" /}
        {eyou:static file="users/skin/css/e-user.css" /}
        {eyou:include file="users/skin/css/diy_css.htm"/}
        {eyou:static file="/public/plugins/layui/css/layui.css" /}
        {eyou:static file="/public/static/common/js/jquery.min.js"/}
        {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
        {eyou:static file="/public/static/common/js/tag_global.js"/}
        <script type="text/javascript" src="__STATIC__/admin/js/jquery-ui/jquery-ui.min.js"></script>
    </head>

    <body>
        {eyou:include file="users/users_header.htm" /} 
        <div class="breadcrumbs"> </div>

        <script type="text/javascript">
            var __lang__ = "<?php echo $admin_lang; ?>";
            window.UEDITOR_HOME_URL = "__ROOT_DIR__/public/plugins/Ueditor/";
            var type20210507 = '';//下载模型的上传类型
            var default_servername20210507 = '';//下载模型的default_servername
            var attr_field20210507 = '';//下载模型的attr_field
            var servername_use20210507 = '';//下载模型的servername_use
        </script>
        {eyou:static file="/public/plugins/Ueditor/ueditor.config.js"/}
        {eyou:static file="/public/plugins/Ueditor/ueditor.all.min.js"/}
        {eyou:static file="/public/plugins/Ueditor/lang/zh-cn/zh-cn.js"/}
        {eyou:static file="/public/plugins/laydate/laydate.js"/}
        {eyou:static file="/public/plugins/layui/layui.js" /}
        <div class="ey-body-bg">
            <div class="ey-body pd0">
                <div class="ey-container w1226">
                    {eyou:include file="users/users_left.htm" /} 
                    <div class="ey-con fr" >
                         <div class="mi-uc-box uc-main-box mi-user-favorite">
                             <div class="uc-content-box portal-content-box">
                                 <div class="uc-context">
                                    <div class="box-hd"><h1 class="title">我要投稿</h1></div> 
                                    <div class="ey-con-forms custom-form mt30">
                                        <form id="post_form">
                                            <input type="hidden" name="channel" value="0">
                                            <div class="item-from-row">
                                                <div class="from-row-l"><span class="red">*</span> 文章标题：</div>
                                                <div class="from-row-r">
                                                    <input type="text" name="title" value="" id="title" class="el-input__inner w500" maxlength="100">
                                                </div>
                                            </div>
                                            <div class="item-from-row">
                                                <div class="from-row-l"><span class="red">*</span> 所属栏目：</div>
                                                <div class="from-row-r">
                                                    <div class="w300 select">
                                                        {$arctype_html}
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="item-from-row">
                                                <div class="from-row-l">TAG标签：</div>
                                                <div class="from-row-r">
                                                    <input type="text" value="" name="tags" id="tags" class="el-input__inner w500" placeholder="多个标签之间用逗号隔开">
                                                </div>
                                            </div>
                                            <div class="item-from-row">
                                                <div class="from-row-l">缩略图：</div>
                                                <div class="from-row-r">
                                                    <a href="javascript:void(0);" onclick="$('#litpicOnclick').trigger('click');" class="img-upload" title="点击上传">
                                                        <div class="y-line" id="litpicYline"></div>
                                                        <div class="x-line" id="litpicXline"></div>
                                                        <img src="" id="litpicImgSrc">
                                                    </a>
                                                    <input type="hidden" name="litpic_inpiut" id="litpicInpiut">
                                                    <input type="file" name="litpic_inpiut_file" id="litpicOnclick" onchange="litpicOnclickFile(this);" style="display: none;">
                                                </div>
                                                <script type="text/javascript">
                                                    function litpicOnclickFile(obj) {
                                                        var file = $(obj)[0].files[0];
                                                        if (!file) return false;
                                                        var formData = new FormData();
                                                        formData.append('_ajax', 1);
                                                        formData.append('file', file);
                                                        formData.append('compress', '1000-1000');
                                                        $.ajax({
                                                            type: 'post',
                                                            url: eyou_basefile + "?m=user&c=Uploadify&a=imageUp",
                                                            data: formData,
                                                            contentType: false,
                                                            processData: false,
                                                            dataType: 'json',
                                                            success: function (res) {
                                                                layer.closeAll();
                                                                if (res.state == 'SUCCESS') {
                                                                    // $('#litpicSpan').show();
                                                                    $("#litpicInpiut").val(res.url);
                                                                    $('#litpicYline, #litpicXline').hide();
                                                                    $("#litpicImgSrc").attr('src', res.url);
                                                                } else {
                                                                    showErrorAlert(res.state);
                                                                }
                                                            },
                                                            error: function(e) {
                                                                layer.closeAll();
                                                                showErrorAlert(e.responseText);
                                                            }
                                                        })
                                                    }
                                                </script>
                                            </div>

                                            <!--下载模型特定字段-->
                                            <div style="display: none;" id="downloadModel">
                                                {eyou:include file="users/article_download_add.htm" /}
                                            </div>

                                            <!--视频模型特定字段-->
                                            <div style="display: none;" id="mediaModel">
                                                {eyou:include file="users/article_media_add.htm" /}
                                            </div>

                                            <!-- 图集模型特定字段 -->
                                            <div style="display: none;" id="imagesModel">
                                                {eyou:include file="users/article_images_add.htm" /}
                                            </div>

                                            <span id="FieldAddonextitem"></span>
                                            <script type="text/javascript">
                                                $(function() {
                                                    var typeid = {$typeid|default='0'};
                                                    if (0 === parseInt(typeid)) typeid = $('#typeid').find('option:selected').val();
                                                    getAddonextitem(0, typeid);

                                                    $('#typeid').change(function() {
                                                        getAddonextitem(1, $(this).val());
                                                    });
                                                });

                                                function getAddonextitem(init, typeid) {
                                                    var channel = $("#typeid option:selected").attr('data-channel');
                                                    $("input[name='channel']").val(channel);

                                                    // 模型字段隐藏、显示处理
                                                    $("#mediaModel").hide();
                                                    $("#imagesModel").hide();
                                                    $("#downloadModel").hide();
                                                    if (3 === parseInt(channel)) {
                                                        // 图集模型特定字段
                                                        $("#imagesModel").show();
                                                    } else if (4 === parseInt(channel)) {
                                                        // 下载模型特定字段
                                                        $("#downloadModel").show();
                                                    } else if (5 === parseInt(channel)) {
                                                        // 视频特定模型字段
                                                        $("#mediaModel").show();
                                                    }

                                                    layer_loading(1 == init ? '正在切换' : '正在加载');
                                                    $.ajax({
                                                        url: "{:url('user/UsersRelease/get_addonextitem')}",
                                                        data: {typeid: typeid, channel: channel, _ajax: 1},
                                                        type:'post',
                                                        success:function(res) {
                                                            layer.closeAll();
                                                            if (res.code == 0) {
                                                                showErrorAlert(res.msg);
                                                            } else {
                                                                $('#FieldAddonextitem').empty().html(res.data.html);
                                                                if (1 == init) {
                                                                    $.each(res.data.htmltextField, function (index, value) {
                                                                        showEditor_1597892187('addonFieldExt_'+value);
                                                                    });
                                                                }
                                                                if (channel == 4) {
                                                                    var download = res.data.download;
                                                                    var users_level_html = '<option value="0" selected>不限会员</option>';
                                                                    $.each(download.users_level, function (index, value) {
                                                                        users_level_html += '<option value="'+value.level_id+'">'+value.level_name+'</option>\n';
                                                                    });
                                                                    $('#arc_level_id').html(users_level_html);
                                                                    if('local' != download.upload_flag){
                                                                        //第三方
                                                                        var upload_button_html = '<button type="button" class="el-button el-button--primary is-plain el-button--small" style="position: relative;z-index: 1;">\n选择多文件\n' +
                                                                            '                       <input type="file" name="file" id="'+download.upload_flag+'File" multiple="multiple" onchange="'+download.upload_flag+'_download__upload(this);" style="position: absolute;top: 0;right: 0;opacity: 0;width: 110px;height: 30px;"/>\n' +
                                                                            '                  </button>';
                                                                        $('#download-layui-upload').prepend(upload_button_html);
                                                                    }else{
                                                                        $("#buttonList").show();
                                                                    }
                                                                    $('#download-layui-upload').attr('data-type',download.upload_flag);
                                                                    if (1 == download.servername_use){
                                                                        $(".th_server_name").show();
                                                                    }
                                                                    type20210507 = download.basic.file_type;
                                                                    default_servername20210507 = download.default_servername;
                                                                    attr_field20210507 = download.attr_field;
                                                                    servername_use20210507 = download.servername_use;
                                                                }
                                                            }
                                                        },
                                                        error: function(e){
                                                            layer.closeAll();
                                                            showErrorAlert(e.responseText);
                                                        }
                                                    });
                                                }
                                            </script>

                                            <div class="item-from-row">
                                                <div class="from-row-l">&nbsp;</div>
                                                <div class="from-row-r">
                                                    <input type="button" data-url="{:url('UsersRelease/article_add', ['_ajax'=>1])}" onclick="addArticle(this);" class="el-button el-button--primary " value="确认提交"/>
                                                </div>
                                            </div>
                                            {$TokenValue}
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <script type="text/javascript">
            // 去除 select中值相同的option(去重)，配合{$arctype_html}使用
            $(function(){
                var channel = $("#typeid option:selected").attr('data-channel');
                if (channel == 3){
                    $("#tupianji").show()
                }
                $("#typeid option").each(function() {
                    var val = $(this).val();
                    if ($("#typeid option[value='" + val + "']").length > 1){
                        $("#typeid option[value='" + val + "']:eq(0)").remove();
                    }
                });
            });

            function addArticle(obj) {
                if (!$('#title').val()) {
                    showErrorMsg('请填写文章标题');
                    $('#title').focus();
                    return false;
                }
                if (0 === parseInt($('#typeid').val())) {
                    showErrorMsg('请选择所属栏目');
                    $('#typeid').focus();
                    return false;
                }
                // 视频模型处理视频地址
                var channel = $("#typeid option:selected").attr('data-channel');
                $("input[name='channel']").val(channel);
                if (5 == channel) urlToStr();

                layer_loading('正在处理');
                $.ajax({
                    url : $(obj).attr('data-url'),
                    data: $('#post_form').serialize(),
                    type: 'post',
                    dataType: 'json',
                    success: function(res) {
                        layer.closeAll();
                        if (1 == res.code) {
                            if (res.data.email) eyUnifiedSendRemind(res.data.email);
                            if (res.data.mobile) eyUnifiedSendRemind(res.data.mobile);
                            showSuccessMsg(res.msg, function() {
                                window.location.href = res.url;
                            });
                        } else {
                            showSuccessMsg(res.msg);
                            if (res.data) $('#'+res.data).focus();
                        }
                    },
                    error : function(e) {
                        layer.closeAll();
                        showErrorAlert(e.responseText);
                    }
                });
            }
        </script> 
        {eyou:include file="users/users_footer.htm" /} 